-- this takes about 43 secs to compute on my Celeron 1.6Ghz

isPrime n [] = True
isPrime n (x:xs)
        | n `mod` x == 0 = False
        | otherwise = isPrime n xs

nats = 2:[3,5..1000000]
primes [] = []
primes (x:xs)
       | isPrime x [3.. (round $ sqrt $ fromIntegral x)] = x : primes xs
       | otherwise = primes xs

main = print $ foldr (+) 0 $ primes nats
